package com.atguigu.algorithm;

import java.util.Scanner;

public class TheLongestSubString {
    public static int LCS(String m,String n){
        int mLen=m.length();
        int nLen=n.length();
        int[][] dp=new int[mLen+1][nLen+1];
        for(int i=1;i<=mLen;i++){
            for(int j=1;j<=nLen;j++){
                if(m.charAt(i-1)==n.charAt(j-1)){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        return dp[mLen][nLen];
    }
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            String m=scanner.next();
            String n=scanner.next();
            System.out.println(LCS(m,n));
        }
    }
}
